package com.library.guard.core.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;


/**
 * @Package: com.library.guard.core.config
 * @ClassName: N01Config
 * @Author: Yin
 * @Date: 16:53
 * @Description: 配置
 */
@Slf4j
@Component
public class N01Config {

    /*
     * RET_OK(0),                   ---执行成功
     * RET_ERR_CONNECT(1),          --连接错误
     * ERR_LINK_FAIL(-1),           ---读写器未连接或连接已断开
     * ERR_BACK_DATA_FAIL(-2),      --返回信息错误，一般出现在返回信息时，是某个具体的操作执行失败，并不影响其他，重新发送即可
     * ERR_CONNECT_FAIL(-3);        ---连接错误，未知的连接方式
     * ERR_OTA_FAIL(-4);            ---OTA升级错误
     * N01_ERR_NOT_LICENSE(-5);     ---未授权
     * N01_ERR_LICENSE_FAIL(-6);    ---授权错误
     *
     */
    /** tcp/id连接 */
    public final static int TCP_IP = 0;

    public final static String DOOR_CALLBACK_TAG_SET_CACHE_KEY = "ZEROANDONE:DOOR:CALLBACK_TAG:";

    public final static String DOOR_REDO_CACHE_KEY = "ZEROANDONE:DOOR:REDO_READ_TAG:";

    public final static int DOOR_REDO_CACHE_KEY_TIMEOUT = 3;

    /** 读取拉取脚本-set(只有rfid tag) */
    public final static String TAG_PULL_SCRIPT =
        "local cacheKey = KEYS[1] local sets = redis.call('SMEMBERS', cacheKey) for i, member in ipairs(sets) do redis.call('SREM', cacheKey, member) end return sets";

    /** 读取拉取脚本-hash(存对象进去了) */
    public final static String TAG_PULL_HASH_SCRIPT =
            "local cacheKey = KEYS[1] local hashKeys = redis.call('HKEYS', cacheKey) if #hashKeys > 0 then local hashVals = redis.call('HMGET',cacheKey,unpack(hashKeys)) redis.call('HDEL' , cacheKey , unpack(hashKeys)) return hashVals else return {} end";

    /** 当前连接 */
    public final static String WS_CONNECTED = "CONNECTED";

//    @Bean
//    public ZeroAndOneApi zeroAndOneApi() {
////        ZeroAndOneApi api = new ZeroAndOneApi();
////        api.connection();
////        api.confInfo();
//        return api;
//    }

}
